{% extends './layout.html'%} {%block main%}

<style>
	h6 {
		margin-bottom: 10px;
	}
	
	body {
		padding: 10px;
	}
	
	html,
	body {
		height: 100%;
	}
	
	label {
		margin-bottom: 8px;
		display: block;
	}
</style>
<form class='layui-form' id='app' method='post' action='/proxy/api/editJingji'>
	<input type="hidden" name='type' value='{{type or info.type | default("jingji")}}' />
	<input type="hidden" name='id' value='{{info.id}}' />
	<div class="layui-form-item">
		<label class="">登录账号</label>
		<div class="">
			<input type="text" class="layui-input newsName" lay-verify="required|name" name='name' value='{{info.name}}' placeholder="账号名称">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">登录密码</label>
		<div class="">
			<input type="password" class="layui-input newsName" name='password' value='{{info.password}}' lay-verify="required|password" placeholder="登录密码">
		</div>
	</div>
	<!--<div class="layui-form-item">
		<label class="">确认登录密码</label>
		<div class="">
			<input type="password" class="layui-input newsName" value='000000' lay-verify="required" placeholder="账号名称">
		</div>
	</div>-->
	<div class="layui-form-item">
		<label class="">公司名称</label>
		<div class="">
			<input type="text" class="layui-input newsName" name='nickname' value='{{info.nickname}}' lay-verify="required" placeholder="公司名称">
		</div>
	</div>
	{%if type != 'normal' %}
	<div class="layui-form-item">
		<label class="">所属账号</label>
		<div class="">
			<select name="parent_id" lay-verify="required|parent_id" lay-search value='{{info.parent_id}}'>
				<option value="">请选择</option>
				{%for item in children%}
				<option value="{{item.id}}">{%if item.type == 'normal'%} 【综合会员】 {%elif item.type == 'jingji'%} 【经纪会员】 {%elif item.type == 'jujian'%} 【居间代理】 {%elif item.type == 'jigou'%} 【机构代理】 {%endif%} {{item.nickname}}</option>
				{%endfor%}
			</select>
		</div>
	</div>
	{%endif%}

	<div class="layui-form-item">
		<label class="">手续费比例(%)</label>
		<div class="">
			<input type="number" min='0' max='100' name='shouxufei' value='{{info.shouxufei}}' class="layui-input newsName" lay-verify="required|shouxufei">
		</div>
	</div>
	{%if type == 'jingji' or type == 'normal' %}
	<div class="layui-form-item">
		<label class="">货款分摊比例(%)</label>
		<div class="">
			<input type="number" min=0 max=100 name=fentan value='{{info.fentan}}' class="layui-input newsName" lay-verify="required|fentan">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">冻结保证金（元）</label>
		<div class="">
			<input type="text" class="layui-input newsName" name=dj_money value='{{info.dj_money}}' lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">保证金阀值（元）</label>
		<div class="">
			<input type="text" class="layui-input newsName" name=limit_money value='{{info.limit_money}}' lay-verify="required">
		</div>
	</div>
	{%endif%}

	<div class="layui-form-item">
		<div>
			<label class="">备注</label>
		</div>

		<div class="">
			<textarea class="layui-textarea  newsName" name='ps' >{{info.ps}}</textarea>
		</div>
	</div>

	<!--<div class="layui-form-item">
		<label class="">公司名称</label>
		<div class="">
			<input type="text" class="layui-input newsName" lay-verify="required" placeholder="公司名称">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">所属账号</label>
		<div class="">
			<input type="text" class="layui-input newsName" lay-verify="required" placeholder="账号名称">
		</div>
	</div>
	<div class="layui-container">
		<div class="layui-row">
		<div class="layui-col-sm6">
			<h6>手续费比例（%）</h6>
			<input type="text" value="000000" class="layui-input search_input">
		</div>
		<div class="layui-col-sm6">
			<h6>手续费比例（%）</h6>
			<input type="text" value="000000" class="layui-input search_input">
		</div>
	</div>
	</div>-->

	<!--<div class="layui-form-item">
		<label class="">&nbsp;</label>
		<div class="layui-inline">
			<div class="layui-input-inline">
			<h6>手续费比例（%）</h6>
			<input type="text" value="000000" class="layui-input search_input">
			</div>
		</div>
		
		<div class="layui-inline">
			<div class="layui-input-inline">
			<h6>货款分摊比例（%）</h6>
			<input type="text" value="000000" class="layui-input search_input">
			</div>
		</div>
		
	</div>
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="">自定义属性</label>
			<div class="">
				<input type="checkbox" name="tuijian" class="tuijian" title="推荐">
				<input type="checkbox" name="shenhe" class="newsStatus" title="审核">
				<input type="checkbox" name="show" class="isShow" title="展示">
			</div>
		</div>
		<div class="layui-inline">
			<label class="">文章作者</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input newsAuthor" lay-verify="required" placeholder="请输入文章作者">
			</div>
		</div>
		<div class="layui-inline">
			<label class="">发布时间</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input newsTime" lay-verify="required|date" onclick="layui.laydate({elem:this})">
			</div>
		</div>
		<div class="layui-inline">
			<label class="">浏览权限</label>
			<div class="layui-input-inline">
				<select name="browseLook" class="newsLook" lay-filter="browseLook">
					<option value="0">开放浏览</option>
					<option value="1">会员浏览</option>
				</select>
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">关键字</label>
		<div class="">
			<input type="text" class="layui-input" placeholder="请输入文章关键字">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">内容摘要</label>
		<div class="">
			<textarea placeholder="请输入内容摘要" class="layui-textarea"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="">文章内容</label>
		<div class="">
			<textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="news_content"></textarea>
		</div>
	</div>-->
	<div class="layui-form-item">
		<div class="">
			<button class="layui-btn" lay-submit="" lay-filter="addNews">立即提交</button>
			<!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
		</div>
	</div>
</form>
{%endblock%} {%block js%}
<script>
	setTimeout(function() {
		var val = $('[name=parent_id]').attr('value');
		val = Number(val)
		if(val > -1) {
			$('dl dd[lay-value=' + val + ']').trigger('click')

		}

	}, 500);

	layui.use('form', function() {
		var form = layui.form;

		form.verify({
			name :function(value,item){
				if(value.length < 6){
					return "账号长度不能小于6";
				}
			},
			password : [
			    /^[\S]{6,12}$/
			    ,'密码必须6到12位，且不能出现空格'
		  	],
		  	shouxufei : function(value){
		  		if(value < 0 || value > 100){
		  			return "手续费比例范围错误";
		  		}
		  	},
		  	fentan : function(value){
		  		if(value < 0 || value > 100){
		  			return "货款分摊比例范围错误";
		  		}
		  	},
		  	parent_id : function(value){
		  		if(value <= 0 ){
		  			return "请选择上级单位";
		  		}
		  	}
		});

		//监听提交
		form.on('submit(addNews)', function(data) {
			console.log(data)
			$.post("/proxy/api/editJingji",data.field,function(json){
				if(json.success){
					layer.msg("保存成功",{icon : 1},function(){
						parent.location.reload();

					})
				}
				else{
					layer.msg(json.msg);
				}
			},'json');
//			layer.msg(JSON.stringify(data.field));
			return false;
		});
	});
</script>
<script type="text/html">
	var info; try{ info = eval('({{info | dump | safe}})'); } catch(e){ } var app = new Vue({ el : '#app', data : { name : 1, password : 2 } }) if(info){ for(var i in info){ app[i] = info[i]; } }
</script>
{%endblock%}